{% extends base_template %}
{% load qa_tags %}
{% load qatrack_tags %}
{% load i18n %}

{% block content %}

<div class="row">
  <div class="col-xs-12">
    {% for site, ses in sites_data %}
      <h2>{% trans "Site" %} :: {% if site %}{{ site }}{% else %}{% trans "Other" %}{% endif %}</h2>
      {% for se in ses %}

        {% if include_description or forloop.first %}
          <table class="table table-condensed table-bordered {% if not include_description %}table-striped{% endif %}">
            <thead>
              <tr class="{% if include_description %}active{% endif %}">
                <th style="width: 12%">{% trans "Service Date" %}</th>
                <th style="width: 12%">{% trans "Unit" %}<div></div></th>
                <th>{% trans "Service Area" %}</th>
                <th>{% trans "Service Type" %}</th>
                <th style="width: 12%">{% trans "Service Time" %}</th>
                <th style="width: 12%">{% trans "Lost Time" %}</th>
                <th style="width: 22%">{% trans "Status" %}</th>
              </tr>
            </thead>
            <tbody>
        {% endif %}

        <tr class="page">
          <td>
            <a href="{{ se.link }}" title="{% trans "Click to view this service event" %}" target="_blank">
              {{ se.service_date }}
            </a>
          </td>
          <td>{{ se.unit_name }}</td>
          <td>{{ se.service_area }}</td>
          <td>{{ se.service_type }}</td>
          <td>
            {% if se.service_time is not None and service_time != "" %}
              {{ se.service_time|hour_min }}
            {% else %}
              <em>{% trans "Not Set" %}</em>
            {% endif %}
          </td>
          <td>
            {% if se.lost_time is not None and lost_time != "" %}
              {{ se.lost_time|hour_min }}
            {% else %}
              <em>{% trans "Not Set" %}</em>
            {% endif %}
          </td>
          <td>{{ se.status }}</td>
        </tr>

        {% if include_description %}
          <tr>
            <th class="text-right" colspan="2">{% trans "Problem Description" %}:</th>
            <td colspan="5">{{ se.problem }}</td>
          </tr>
          <tr>
            <th class="text-right" colspan="2">{% trans "Work Description" %}:</th>
            <td colspan="5">{{ se.work }}</td>
          </tr>
        {% endif %}

        {% if include_description or forloop.last %}
            </tbody>
          </table>
        {% endif %}

      {% endfor %}
    {% endfor %}
  </div>
</div>

{% endblock %}
